package net.entelijan.cobean.examples.showcase.progress;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import net.entelijan.cobean.core.ICobean;
import net.entelijan.cobean.progress.DefaultProgressInitializer;
import net.entelijan.scf.IShowcase;

// TODO Make some automated testcase from that shocase
public class ProgressShowcase implements IShowcase<ProgressPanel> {

	private ICobean<Integer> progressCobean;

	public ProgressShowcase() {
		super();
	}

	@Override
	public void init(final ProgressPanel panel) {

		{
			DefaultProgressInitializer init = new DefaultProgressInitializer();
			init.setCoProgress(panel.getProgressBar());
			progressCobean = init.initialize();
		}

		panel.getSet0Button().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				progressCobean.setValue(0);
			}

		});
		panel.getSet100Button().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				progressCobean.setValue(100);
			}

		});
		panel.getSetRandomButton().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				progressCobean.setValue(new Random().nextInt(100));
			}

		});
	}

}
